var num=1;//记录当前哪张图片显示
var time=0;//时间
var times=0;//次数
function setCss(){
    var all=document.getElementsByTagName("*").style;
    all.padding="0px";
    all.margin="0px";
}
function show(id){
    document.getElementById(id).style.display="block";
    document.getElementById(id+5).style.borderColor='white';
}
function hide(id){
    document.getElementById(id).style.display="none";
    document.getElementById(id+5).style.borderColor='gray';
}
function clock(){ /*设置css属性和自动切换图片*/
    var all=document.getElementsByTagName("*");
    for(var i=0;i<all.length;i++){
        all[i].style.margin="0px";
        all[i].style.padding="0px";
    }

    var big=document.getElementById("big");
    big.style.margin="100px auto 0px auto";
    big.style.width="500px";

    var setPosition=document.getElementsByClassName("set-position");
    for(var i=0;i<setPosition.length;i++){
        setPosition[i].style.position="absolute";
    }

    var button=document.getElementsByClassName("button");
    for(var i=0;i<button.length;i++){
        button[i].style.width="40px";
        button[i].style.height="120px";
        button[i].style.border="none";
        button[i].style.marginTop="80px";
    }

    var text=document.getElementsByClassName("text");
    for(var i=0;i<text.length;i++){
        text[i].style.width="500px";
        text[i].style.marginTop="260px";
        text[i].style.textAlign="center";
    }

    var line=document.getElementsByClassName("line");
    for(var i=0;i<line.length;i++){
        line[i].style.marginRight="5px";
        line[i].style.width="19px";
        line[i].style.borderBottom="8px solid	gray";
        line[i].style.float="left";
    }

    var alline=document.getElementById("allline");
    alline.style.margin="300px 0px 0px 300px";

    var content=document.getElementsByClassName("content");
    for(var i=0;i<content.length;i++){
        content[i].style.display="none";
    }

    var right=document.getElementById("right");
    right.style.marginLeft="460px";
    right.style.background="url(img/right.png)";

    var left=document.getElementById("left");
    left.style.background="url(img/left.png)";

    var clear=document.getElementsByClassName("clear");
    for(var i=0;i<clear.length;i++){
        clear[i].style.clear="both";
    }

    if(num>5){
        num=1;
    }
    changeLine(num)
    num++;
    if(times){
        time=10000;
        times=0;
    }
    else
        time=0;


    window.setTimeout("clock()",2000+time);
}
function changeTimes(){
    times=1;
}
function changeLine(id){
    for(var i=1;i<=5;i++){
        if(id==i){
            show(i);
            num=i;
        }
        else
            hide(i);
    }
}
function changeButton(select){/*按下左右边按钮时改变按顺序图片的显示*/
    for(var i=1;i<=5;i++){
        var get=document.getElementById(i).style.display;
        if(select==1){
            if(get!='none'){
                hide(i);
                if(i==1){
                    show(5);
                    num=5;
                }
                else{
                    show(i-1);
                    num=i-1;
                }
                break;
            }
        }
        else{
            if(get!='none'){
                hide(i);
                if(i==5){
                    show(1);
                    num=1;
                }
                else{
                    show(i+1);
                    num=i+1;
                }
                break;
            }
        }

    }
}